<!-- 付款申请单付款明细 -->
<template>
	<view class="">
		<u-sticky offset-top="0">
			<common-search
				class="search"
				v-model="queryParam.billNo" 
				:screenShow="screenShow"
				:isScreen="false"
				@screenclick="screenclick"
				@searchMsg="searchMsg"
				placeholder="请输入单据编号"
			></common-search>
		</u-sticky>
		<view class="page" :style="!isData?'display:flex;width: 100vw;height:100vh;align-items:center;justify-content: center;':''">
			<template v-if="isData">
				<view class="list" v-for="(item,index) in dataList" :key="index">
					<view class="">
						<view class="option">
							<view class="lf">单据编号</view>
							<view class="rl" @click="onContarctName(item)" style="color: #1E6FFF;">{{ item.billNo }}</view>
						</view>
						<view class="option">
							<view class="lf">申请公司</view>
							<view class="rl">{{ item.applicant_dictText }}</view>
						</view>
						<view class="option">
							<view class="lf">申请团队</view>
							<view class="rl">{{ item.teamId_dictText }}</view>
						</view>
						<view class="option">
							<view class="lf">支付金额</view>
							<view class="rl" >{{ item.payAmount }}</view>
						</view>
						<view class="option">
							<view class="lf">收款人</view>
							<view class="rl" >{{ item.payeeName_dictText }}</view>
						</view>
						<view class="option">
							<view class="lf">收款方式</view>
							<view class="rl">{{ item.payMode_dictText }}</view>
						</view>
					</view>
				</view>
				<!-- 加载更多显示 -->
				<view class=""><u-loadmore :status="statusLoadmore" /></view>
			</template>
			<view v-else>
				<u-empty
					mode="data"
					icon="/static/empty/data.png"
				>
				</u-empty>
			</view>
		</view>
		
		<u-toast ref="uToast"></u-toast>
	</view>
</template>
<script>
	import { erpCompanyFilesList } from '@/api/index.js';
	import CommonSearch from '../../components/CommonSearch.vue'
	import http from '@/utils/request/index.js'
	export default {
		components: {
			CommonSearch
		},
		data() {
			return {
				relReimbursementBillId: '', // 选中的id
				page: {
					pageNo: 1,
					pageSize: 10,
				},
				dataList: [] ,// 列表
				isData: true, // 判断是否有数据  true 代表有 false 代表无
				statusLoadmore: 'loadmore', // 通过status设置组件的状态，加载前值为loadmore，加载中为loading，没有数据为nomore
				screenShow: false, // 筛选弹窗
				// 传的参数
				queryParam: {
					billNo: ''
				},
				
				objectField: '', // 点击确认需要修改的字段
			}
		},
		onLoad(options) {
			this.relReimbursementBillId = options.relReimbursementBillId || ''
			this.geterpOmcTeamManagerList() // 获取列表
		},
		methods: {
			// 获取列表
			geterpOmcTeamManagerList () {
				this.statusLoadmore = 'loading' // 加载中
				var params = {
					column: 'createTime',
					order: 'desc',
					pageNo: this.page.pageNo,
					pageSize: this.page.pageSize
				}
				if (this.relReimbursementBillId) {
					params.relReimbursementBillId = this.relReimbursementBillId
					params.bpmStatus = '3'
				}
				if (this.queryParam.billNo) {
					params.billNo = this.queryParam.billNo
				}
				http.get('/api/erp/finance/payment/erpFinancePaymentSlip/allList', params).then(res => {
					if (res.success) {
						 // 判断首次加载是否有数据
						if (this.page.pageNo == 1){
							if (res.result.records&&res.result.records.length) {
								this.isData = true
							} else {
								this.isData = false
							}
						}
						if (res.result.records&&res.result.records.length){
							if (res.result.records.length >= 10 ) {
								this.statusLoadmore = 'loadmore'
							} else {
								this.statusLoadmore = 'nomore'
							}
						}else {
							this.statusLoadmore = 'nomore'
						}
						if (this.page.pageNo == 1){
							this.dataList = res.result.records
						} else {
							this.dataList = this.dataList.concat(res.result.records)
						}
					}
				})
			},
			
			// 点击编号
			onContarctName (item) {
				uni.redirectTo({
					url:'/pages/reportFilesList/ErpFinancePaymentSlipForm?id=' + item.id
				})
			},
			
			// 点击筛选
			screenclick () {
				this.screenShow = !this.screenShow
			},
			// 输入内容
			searchMsg () {
				this.page.pageNo = 1 // 页数归1
				this.dataList = [] // 清空列表
				this.geterpOmcTeamManagerList() // 获取列表
			},
			
			// 点击确定
			onConfirm () {
				var item = ''
				this.dataList.map(value => {
					if (value.isChecker) {
						item = value
					} else {
						// error
					}
				})
				if (item) {
					let arr = this.objectField.split('.')
					let pages = getCurrentPages() //获取所有页面栈实例列表
					let nowPage = pages[pages.length - 1] //当前页页面实例
					let prevPage = pages[pages.length - 2] //上一页页面实例
					if (prevPage.$vm) {
						if (arr.length == 1) {
							prevPage.$vm[this.objectField] = item.id //修改上一页data里面的tagIndex 参数值
						} else if (arr.length == 2) {
							prevPage.$vm[arr[0]][arr[1]] = item.id //修改上一页data里面的tagIndex 参数值
						}
						
					}
					uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
					delta: 1
					})
				} else {
					this.$refs.uToast.show({
						type: 'error',
						icon: 'none',
						message: '请选择数据'
					})
				}
			}
			
			
		},
		onReachBottom() {
			if (this.statusLoadmore == 'nomore') return false
			this.page.pageNo = ++ this.page.pageNo;
			this.geterpOmcTeamManagerList()
		}
		
	}
</script>
<style lang="scss" scoped>
.page {
	padding: 0 20rpx 20rpx 20rpx;
	.list{
		border-radius: 10rpx;
		box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.1);
		padding: 12rpx 20rpx 20rpx 20rpx;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;
	}
}

// 按钮
.btn{
	position: fixed;
	bottom: 20rpx;
	width: 95%;
}
</style>

